#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n;
ll sum, _sum;

ll f1(string& s)
{
    ll num = 0;
    for (ll i = 0;i < s.length();i++)
        num = num * 10 + s[i] - '0';
    return num;
}

ll f2(string& s) {
    ll num = 0;
    for (ll i = 0;i < s.length();i++)
        num = num * 10 + (s[i] == '0' ? 8 : s[i] - '0');
    return num;
}

void solve()
{
    cin >> n;
    for (ll i = 1;i <= n;i++) {
        string s; cin >> s;
        sum += f1(s);
        _sum += f2(s);
    }
    cout << _sum - sum << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
    // #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}